<template>
	<view class="content">
		<image src="../../static/images/success.png" mode=""></image>
		<text>报名成功</text>
		<text>自动跳转中{{count}}</text>
	</view>
</template>

<script setup>
	import {
		onUnload
	} from '@dcloudio/uni-app';
	import {
		ref,
		onMounted,
		onBeforeUnmount
	} from 'vue';
	const count = ref(3);
	let timer = null;
	onMounted(() => {
		timer = setInterval(() => {
			if (count.value > 0) {
				count.value--;
			} else {
				clearInterval(timer);
				uni.switchTab({
					url: '/pages/index/index',
				});
			}
		}, 1000);
	});

	onUnload(() => {
		wx.reLaunch({
			url: '/pages/index/index'
		});
	})

	onBeforeUnmount(() => {
		if (timer) {
			clearInterval(timer);
		}
	});
</script>

<style scoped>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding: 70px 0;
		gap: 30px;
	}

	image {
		width: 120px;
		height: 120px;
	}

	text:nth-child(1) {
		font-size: 22px;
		font-weight: bold;
	}
	
</style>